package com.health.db.dao.user.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.user.IStuffListDao;
import com.health.db.mapper.StuffListMapper;
import com.health.db.model.StuffList;
import com.health.redis.RedisConstants;

/**
 * 科室医生
 * @author YC
 *
 */
@Component("StuffListDao")
public class StuffListDaoImpl extends ServiceInterface implements
		IStuffListDao{

	@Autowired
	StuffListMapper stuffListMapper;

	@Override
	public List<StuffList> selectByDepartmentId(Integer departmentId)  {
		// TODO Auto-generated method stub
		
		getRedisOperatiorLogic();
	    String key =RedisConstants.NEWDepartmentListMapper+":departmentId:"+departmentId.intValue();
	    
	    Object object=null;
	    List<StuffList>  list = null;
      
        if(redisOperatiorLogic.isJedisIsConnected())
        {    
            object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
         }
         if(null!=object){
        	 if (!object.equals("")) {
        		 list = ( List<StuffList> ) object;
			}
         }else{
        	 list= stuffListMapper.selectByDepartmentId(departmentId);
          if(redisOperatiorLogic.isJedisIsConnected())
            {
                redisOperatiorLogic.setEx(key, list,  getOrderRedisGroupNo("1"));
             }
         }
        return list;
		
	}



	@Override
	public StuffList selectByStuffId(Long stuffId) {
		// TODO Auto-generated method stub
		
		getRedisOperatiorLogic();
	    String key =RedisConstants.NEWDepartmentListMapper+":stuffId:"+stuffId.longValue();
	    
	    Object object=null;
	    StuffList list = null;
      
        if(redisOperatiorLogic.isJedisIsConnected())
        {    
            object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
         }
         if(null!=object){
        	 if (!object.equals("")) {
        		 list = ( StuffList) object;
			}
         }else{
        	 list= stuffListMapper.selectByStuffId(stuffId);
          if(redisOperatiorLogic.isJedisIsConnected())
            {
                redisOperatiorLogic.setEx(key, list,  getOrderRedisGroupNo("1"));
             }
         }
        return list;
	}



	public StuffListMapper getStuffListMapper() {
		return stuffListMapper;
	}



	public void setStuffListMapper(StuffListMapper stuffListMapper) {
		this.stuffListMapper = stuffListMapper;
	}

	


}
